﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CNPC.Models
{
    public class cnpcRepository
    {
        private cnpcDataContext db = new cnpcDataContext();

        /// <summary>
        /// 查询数据的方法
        /// </summary>
        /// <returns></returns>
        public IQueryable<name> FindAllName()
        {
            return db.names;
        }

        public IQueryable<name> FindNameBySearch()
        {
            return from name in db.names
                   where name.name_string.Contains("Pternopetalum")
                   orderby name.name_string
                   select name;            
        }
        public name GetName(int nameId)
        {
            return db.names.SingleOrDefault(n=> n.id==nameId);
        }
    }
}
